# def lianfen(x,a,b):
#     return x * b + a

# 2得了连分
# x1 ,x2,x3 = 1,3,7
# y1,y2,y3 = 1,2,5
# index = 4
# for x in range(97):
#     x1,x2,x3= x2,x3, lianfen(2,x2,x3)
#     y1,y2,y3= y2,y3, lianfen(2,y2,y3)
#     print index, x3,y3
#     index = index + 1

# e的连分
x1 ,x2,x3 = 2,3,8
y1,y2,y3 = 1,1,3
for i,x in enumerate(range(4,101)):
    k = 2 * (x / 3) if x%3 ==0 else 1
    x1,x2,x3= x2,x3, k* x3 + x2
    y1,y2,y3= y2,y3, k* x3 + x2
    if i+ 4 == 100:
        print i+4, x3, sum([int(x) for x in str(x3)])
